﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReArrangeRecordDAL : SyncBase<Model.ReArrangeRecord>
    {
        static ReArrangeRecordDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReArrangeRecordDAL.addSQL = @"insert into TempReArrangeRecord(
			ResourceID,LessonID,GradeCode,GradeName,ClassID,ClassName,UserID,ArrangeTime,CutoffTime,ResourceType,Status)
			 values (
			@ResourceID,@LessonID,@GradeCode,@GradeName,@ClassID,@ClassName,@UserID,@ArrangeTime,@CutoffTime,@ResourceType,@Status)";
            ReArrangeRecordDAL.tbName = "TempReArrangeRecord";
            ReArrangeRecordDAL.remoteUrl = "/Ayyfford/AddReArrangeRecord";
            ReArrangeRecordDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}),",
                            t.ResourceID.NullNumber(), t.LessonID.NullNumber(), t.GradeCode.NullString(), t.GradeName.NullString(), t.ClassID.NullNumber(), t.ClassName.NullString(), t.UserID.NullNumber(), t.ArrangeTime.NullDate(), t.CutoffTime.NullDate(), t.ResourceType.NullString(), t.Status.NullNumber());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReArrangeRecord t)
        {
            SyncBase<Model.ReArrangeRecord>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReArrangeRecord>.AsyncData();
        }
    }
}
